package Demo4;

class Count{
    public int count=0;
   synchronized public void add(){
        count++;
    }
}

public class Main3 {
    public static void main(String[] args) throws InterruptedException {
        Count count=new Count();
     Thread t1=new Thread(()->{
         for (int i = 0; i <50000 ; i++) {
             count.add();
         }
     });

        Thread t2=new Thread(()->{
            for (int i = 0; i <50000 ; i++) {
                count.add();
            }
        });

        t1.start();
        t2.start();

        t1.join();
        t2.join();

        System.out.println(count.count);
    }
}
